﻿using UnityEngine;

namespace MLog.Sample {
    public class ApplicationListener : MonoBehaviour {
#if UNITY_5_3_OR_NEWER
        [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
        public static void AutoInitialize() {
            MLog.Initialize();
        }
#else
        private static ApplicationListener Instance;

        private void Awake() {
            if (Instance == null) {
                Instance = this;
                DontDestroyOnLoad(transform.gameObject);
                MLog.Initialize();
            }
        }
#endif


        private void OnApplicationQuit() {
            MLog.Destroy();
#if !UNITY_5_3_OR_NEWER
            Instance = null;
#endif
        }
    }
}